home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / A-line / Scripts / MakeSource.pm < prev    next >
Encoding:
Text File  |  2000-06-24  |  1000 b   |  51 lines

  1. #!perl -w
  2. # Special MPW glue
  3. undef;
  4.  
  5. package MakeSource;
  6.  
  7. require Exporter;
  8. @ISA = 'Exporter';
  9. @EXPORT = qw(MakeSource);
  10.  
  11. # MakeSource
  12.  
  13. use SourceList;
  14.  
  15. use strict;
  16.  
  17. Main() unless caller;
  18.  
  19. sub Main {
  20.     my $output = MakeSource(@ARGV);
  21.     foreach (@$output) {
  22.         print;
  23.     }
  24. }
  25.  
  26. sub MakeSource {
  27.     my ($sourcesref) = SourceList::Sources(@_);
  28.     my (%pathnames, @files);
  29.     my @output;
  30.     push @output, "# Make statements generated automatically by MakeSource.\n\n";
  31.     foreach my $src (@$sourcesref) {
  32.         my $pathname = $src->{DIR};
  33.         my $filename = $src->{FILE};
  34.         my $ext = '';
  35.         $filename =~ /\.(\w+)$/ and $ext = $1;
  36.         push @{$pathnames{$ext}}, $pathname unless grep { $_ eq $pathname; } @{$pathnames{$ext}};
  37.         push @files, $filename;
  38.     }
  39.     foreach my $ext (sort keys %pathnames) {
  40.         length $ext or $ext = "NULL";
  41.         push @output, ".SOURCE.$ext : " 
  42.             . join('', '"', join('" "', @{$pathnames{$ext}}), '"', "\n");
  43.     }
  44.     push @output, "\n";
  45.     push @output, "SRCS = " . join(' ', @files) . "\n";
  46.     
  47.     return \@output;
  48. }
  49.  
  50. 1;
  51.